package com.ruoyi.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.service.impl.DangerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/danger")
public class DangerController {
    @Autowired
    DangerService dangerService;
    @Anonymous
    @PostMapping("/filePath/{id}")
    public AjaxResult uploadFile(@PathVariable int id, @RequestParam MultipartFile file) throws Exception {
        return dangerService.uploadFile(id,file);
    }

    @Anonymous
    @GetMapping("/selectAll")
    public AjaxResult selectAll() throws Exception {
        return AjaxResult.success(dangerService.selectAll());
    }

    @Anonymous
    @GetMapping("/selectById/{id}")
    public AjaxResult selectById(@PathVariable int id) throws Exception {
        return AjaxResult.success(dangerService.selectById(id));
    }


}
